﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;

namespace EmProductCenter.pxjd
{
    public partial class xxhc : System.Web.UI.Page
    {
        Common.CommonClass common = new Common.CommonClass();
        BLL.ePioneer_Lecturer bllEPL = new BLL.ePioneer_Lecturer();
        public string strTeach = "";
        public string strListTeach = "";
        public string strTopCourse = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetTopCourse();
                GetTeachHtml();
                if (Session["LoginName"] != null)
                    hid_userName.Value = Session["LoginName"].ToString();
            }
        }

        /// <summary>
        /// 获取讲师信息
        /// </summary>
        private void GetTeachHtml()
        {
            List<Model.ePioneer_Lecturer> list = bllEPL.GetModelList("1=1");
            StringBuilder str = new StringBuilder();
            StringBuilder strList = new StringBuilder();
            str.Append("<a href='javascript:void(0);'>请选择专家</a>");
            foreach (Model.ePioneer_Lecturer model in list)
            {
                str.Append("<a href='javascript:void(0);'>" + model.Lecturer + "</a>");
                strList.Append("<li><div class='item'><a href='javascript:void(0);' onclick=\"OpenTeachInfo('" + model.Lecturer + "');\">");
                if (model.PicUrl != null && model.PicUrl != "")
                    strList.Append("<image src='" + model.PicUrl + "' width='74px' height='100px' />");
                else
                    strList.Append("<image src='../image/master_face_1.jpg' width='74px' height='100px' />");
                strList.Append("<p>" + model.Lecturer + "</p></a></div></li>");
            }
            strTeach = str.ToString();
            strListTeach = strList.ToString();
        }

        /// <summary>
        /// 精选课程推荐
        /// </summary>
        /// <returns></returns>
        private void GetTopCourse()
        {
            BLL.ePioneer_CourseInfo bllEPCI = new BLL.ePioneer_CourseInfo();
            DataRow[] list = bllEPCI.GetCourseInfo();
            int count = list.Count();
            StringBuilder strCour = new StringBuilder();
            strCour.Append("<p class='title'>全国精选课程推荐</p>");
            if (count == 0)
                strCour.Append("<p>暂无数据</p>");
            for (int i = 0; i < 8; i++)
            {
                if (i >= count)
                {
                    break;
                }

                strCour.Append("<p><a href='javascript:void(0);' onclick=\"OpenCourseInfo('" + list[i]["Id"] + "');\">" + list[i]["Title"] + "</a><span>" + list[i]["Location"] + "</span></p>");
            }
            strTopCourse = strCour.ToString();
        }
    }
}